<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;

/**
 * 云端量表
 */
class RatingScaleCloudModel extends BaseModel
{
    protected $name = 'rating_scale_cloud';

    /**
     * 新增数据验证
     * @return array
     */
    public function addValidate()
    {
        return [
            'uid|分享人ID'  => 'require',
            'channel|渠道'  => 'require',
            'channel_id|渠道id'  => 'require',
            'name|量表名'  => 'require',
            'cover|封面图'  => 'require',
            'download_price|下载价格'  => 'require',
        ];
    }

    /**
     * 关联量表
     * @return BelongsTo
     */
    public function RatingScale(): BelongsTo
    {
        return $this->belongsTo('RatingScaleModel', 'rating_scale_id')->bind([
            'rating_scale_name' => 'name',
            'rating_scale_cover' => 'cover',
            'rating_scale_introduce' => 'introduce',
            'rating_scale_notice' => 'notice',
            'RatingScaleQuestion',
        ]);
    }

    public function user()
    {
        return $this->belongsTo('UserModel', 'uid')->bind([
            'user_name' => 'name',
            'user_avatar' => 'avatar',
        ]);
    }
}